<?php
/**
 * @package EasyTop
 * @subpackage PlusTheme
 */
get_header();
?>
<!-- ####################################################################################################### -->


<div class="wrapper col2">
  <div id="breadcrumb">
    <ul>
      <?php echo easytop_breadcrumb();?>
    </ul>
  </div>
</div>
  <!--
    <ul>
      <li class="first">You Are Here</li>
      <li>&#187;</li>
      <li><a href="#">Home</a></li>
      <li>&#187;</li>
      <li><a href="#">Grand Parent</a></li>
      <li>&#187;</li>
      <li><a href="#">Parent</a></li>
      <li>&#187;</li>
      <li class="current"><a href="#">Child</a></li>
    </ul>
-->
<!-- ####################################################################################################### -->
<div class="wrapper col3">
  <div id="container">
    <div id="content">
	<?php $tempcounter==0; $loopcounter = 0;?>
<?php if (have_posts()) : while (have_posts() && $tempcounter<9) : the_post(); $tempcounter++; $loopcounter++;?>
	<?php $postclass = '-left'?>
	<?php 
	if ($loopcounter == 1) { $postclass = '-left product-separator hseparator';}
	if ($loopcounter == 2) { $postclass = '-left hseparator';}
	if ($loopcounter == 3) { $postclass = '-right hseparator';}
	?>
	<div class="product<?echo $postclass?>"> 	
	<?php
	$id =$post->ID;
	$the_content =$wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = $id");
	$pattern = '!<img.*?src="(.*?)"!';
	preg_match_all($pattern, $the_content, $matches);
	$image_src = $matches['1'][0];
	if(!$image_src) $image_src = get_bloginfo('stylesheet_directory').'/images/thumbnail.jpg';
	$image_src = get_bloginfo('stylesheet_directory').'/phpthumb/phpThumb.php?src='.$image_src.'&amp;w=180&amp;h=135&amp;zc=1';
	?>
	<a class="crop-foto" href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>" >
	<img src="<?php echo $image_src; ?>" alt="<?php the_title(); ?>" />
	</a>
	<h2 class="magz-gallery-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>" class="title"><?php the_title(); ?></a></h2>
	</div>

	<?php if ($loopcounter == 3) { $loopcounter =0; ?> <div class="clear" ></div> <?php } ?>
	
	<?php endwhile; else: ?>
	<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
	<?php endif; ?>
	
	<div class="product-nav">
		<?php if(function_exists('wp_pagenavi')) : wp_pagenavi(); else : ?>
		<div class="alignleft"><?php next_posts_link('&laquo; Older Products') ?></div>
		<div class="alignright"><?php previous_posts_link('Newer Products &raquo;') ?></div>
		<hr class="clear"/>
		<?php endif; ?>
	</div>
	
    </div>
    <?php get_sidebar();?>
    <br class="clear" />
  </div>
</div>

<?php get_footer(); ?>